package utils;

import java.util.ArrayList;

/**
 * 
 * 
 * TODO:
 * 	dodawanie godziny na poczatku wpisu
 */
import javax.swing.JTextArea;

public class TyranizatorLogger {
	private ArrayList<String> logger;
	private JTextArea textPane;
	
	public TyranizatorLogger(JTextArea aTextPane) {
		logger = new ArrayList<>();
		textPane = aTextPane;
	}

	public ArrayList<String> getLogger() {
		return logger;
	}

	public void setLogger(ArrayList<String> logger) {
		this.logger = logger;
	}

	public void addLog(String msg) {
		logger.add(msg);
		showOnTextPane();
	}

	public String getLastMsg() {
		return logger.get(logger.size() - 1);
	}

	public String toString() {
		StringBuilder sb = new StringBuilder();

		for (String it : logger) {
			sb.append(it + "\n");
		}

		return sb.toString();

	}
	
	public void showOnTextPane(){
		textPane.setText(toString());
	}

}
